/*
 * db_mysql.hpp
 *
 *  Created on: 2022年11月7日
 *      Author: dylan
 */

#ifndef _DM_OS_DB_DB_MYSQL_HPP_
#define _DM_OS_DB_DB_MYSQL_HPP_
#include <os/db/db.hpp>
#include <os/db/resultset_mysql.hpp>

#include <cppconn/driver.h>
#include <cppconn/connection.h>

namespace iotplat {
    class CDbMysql : public CDb {
    public:
        CDbMysql(const char *dbName, const char *host = "localhost");

        ~CDbMysql();

        EDbType dbType();

        bool isConnected();

        bool connect(const char *user, const char *pw);

        void disconnect();

        bool exec(const char *sql);

        int64_t execWithLastId(const char *sql);

        CResultSet *query(const char *sql);

        CResultSet *getTables(const char *pattern);

    private:
        sql::Driver *m_driver;
        sql::Connection *m_con;
    };
}

#endif /* _DM_OS_DB_DB_MYSQL_HPP_ */
